********************************************************************************		
********************** Party assessments: main regressions *********************
********************************************************************************	
		
	*** use stacked dataset (with CDU and CSU as seperate entries)
		use "ZA6804_v6-0-0_processed_stacked_scalo.dta", clear
		
		
	*** Regression table
	
		* perceived party position dummies
		mixed skalometer i.w7_party_highertaxes_dum i.w7_party_migrrestr_dum ///
				lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party  || personid:
		eststo m1
		
		* perceived left-authoritarian position
		mixed skalometer w7_party_leftauth ///
				lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m2
		
		* perceived quadrants
		mixed skalometer w7_party_leftauth w7_party_rightlib w7_party_rightauth w7_party_leftlib  ///
				lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m3	
		
		* perceived party position dummies X MIP
		mixed skalometer i.w7_party_highertaxes_dum##i.w7_mip_econ i.w7_party_migrrestr_dum##i.w7_mip_immi ///
				lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m4
		
		* perceived party position X MIP
		mixed skalometer c.w7_party_highertaxes_st##i.w7_mip_econ c.w7_party_migrrestr_st##i.w7_mip_immi ///
				lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m5
		
		* perceived distance X MIP
		mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
			lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m6 
		
		* perceived distance X MIP, with perceived left-right distance
		mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
			dist_subj_leftright age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m7 
								
		* perceived distance X MIP, with perceived left-right distance; with party fixed effect
		mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
				i.obs_party ///
				dist_subj_leftright age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m8 
		
		* perceived distance X MIP, with perceived left-right distance; MIP X party 
		mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
				c.w7_mip_econ##i.obs_party c.w7_mip_immi##i.obs_party ///
				dist_subj_leftright age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m9 
		
		* perceived distance X MIP, with perceived left-right distance; MIP X party; party identification
		mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
				c.w7_mip_econ##i.obs_party c.w7_mip_immi##i.obs_party ///
				dist_subj_leftright partyid_dummy age_party female_party east_party christian_party rural_party income_party educat_party || personid:
		eststo m10 
			
		* write table
	esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 ///
				using Table_scalo.rtf, drop(age_party female_party east_party christian_party rural_party income_party educat_party 0.w7_party_highertaxes_dum 0.w7_mip_econ 0.w7_party_highertaxes_dum#0.w7_mip_econ 0.w7_party_migrrestr_dum 0.w7_mip_immi 0.w7_party_migrrestr_dum#0.w7_mip_immi 1.obs_party 2.obs_party 3.obs_party 4.obs_party 5.obs_party 6.obs_party 7.obs_party) ///
				 order(1.w7_party_highertaxes_dum 1.w7_party_migrrestr_dum w7_party_leftauth w7_party_rightlib w7_party_rightauth w7_party_leftlib 1.w7_mip_econ 1.w7_mip_immi 1.w7_party_highertaxes_dum#1.w7_mip_econ 1.w7_party_migrrestr_dum#1.w7_mip_immi w7_party_highertaxes_st w7_party_migrrestr_st 1.w7_mip_econ#c.w7_party_highertaxes_st 1.w7_mip_immi#c.w7_party_migrrestr_st dist_subj_econ dist_subj_migration 1.w7_mip_econ#c.dist_subj_econ 1.w7_mip_immi#c.dist_subj_migration lrcat_party dist_subj_leftright partyid_dummy) ///
				 b(%8.2f) se(%8.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(20) nogaps compress noomitted label replace noconstant nomtitles 
		
		/*
		* Compare the model with transformed controls, to model with control X party interactions
				mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
					c.w7_mip_econ##i.obs_party c.w7_mip_immi##i.obs_party ///
					lrcat_party age_party female_party east_party christian_party rural_party income_party educat_party  || personid:
				
				mixed skalometer c.dist_subj_econ##i.w7_mip_econ c.dist_subj_migration##i.w7_mip_immi ///
					c.w7_mip_econ##i.obs_party c.w7_mip_immi##i.obs_party ///
					i.w7_leftright_cat##i.obs_party c.age##i.obs_party female##i.obs_party east##i.obs_party christian_d##i.obs_party ///
					rural2##i.obs_party c.income##i.obs_party educat##i.obs_party  || personid:
		*/
		
		
	*** Marginal effect plots
			
			* FIGURE: M4 
			
			estimates restore m4
				
			margins, dydx(w7_party_highertaxes_dum) at(w7_mip_econ=(0 1)) post
			coefplot, level(95 85) coeflabels(1._at="MIP immigration or other" 2._at="MIP economic") ///
				title("Effect of perceived congruent economic position on party evaluations") ///
					scheme(plottig) name(gr1, replace) nodraw
			
		
			estimates restore m4
		
			margins, dydx(w7_party_migrrestr_dum) at(w7_mip_immi=(0 1)) post
			coefplot, level(95 85) coeflabels(1._at="MIP economic or other" 2._at="MIP immigration") ///
					title("Effect of perceived congruent position on immigration on party evaluations") ///
					scheme(plottig) name(gr2, replace) nodraw
					
			graph combine gr1 gr2, cols(1) xcommon iscale(*1.3) name(model4, replace)
			
				
			* FIGURE: M5 
			
			estimates restore m5
				
			margins, dydx(w7_party_highertaxes_st) at(w7_mip_econ=(0 1)) post
			coefplot, level(95 85) coeflabels(1._at="MIP immigration or other" 2._at="MIP economic") ///
				title("Effect of perceived economic position on party evaluations") ///
					scheme(plottig) name(gr1, replace) nodraw
		
			estimates restore m5
		
			margins, dydx(w7_party_migrrestr_st) at(w7_mip_immi=(0 1)) post
			coefplot, level(95 85) coeflabels(1._at="MIP economic or other" 2._at="MIP immigration") ///
					title("Effect of perceived position on immigration on party evaluations") ///
					scheme(plottig) name(gr2, replace) nodraw
					
			graph combine gr1 gr2, cols(1) xcommon iscale(*1.3) name(model5, replace) 

			
			* FIGURE: M6 
			
			estimates restore m6
				
			margins, dydx(dist_subj_econ) at(w7_mip_econ=(0 1)) post
			coefplot, level(95 85) coeflabels(1._at="MIP immigration or other" 2._at="MIP economic") ///
				title("Effect of perceived economic distance on party evaluations") ///
					scheme(plottig) name(gr1, replace) nodraw
		
			estimates restore m6
		
			margins, dydx(dist_subj_migration) at(w7_mip_immi=(0 1)) post
			coefplot, level(95 85) coeflabels(1._at="MIP economic or other" 2._at="MIP immigration") ///
					title("Effect of perceived distance on immigration on party evaluations") ///
					scheme(plottig) name(gr2, replace) nodraw
					
			graph combine gr1 gr2, cols(1) xcommon iscale(*1.2) name(model6, replace)
